将开发板的启动模式配置成SD卡启动,将TF卡插入到卡槽中。
用网线将开发板上的PS_NET网口接入到开发环境所在的局域网或者直接和电脑主机直连。
将开发板的PS_UART串口和主机连接,板子上电。
我们可以通过主机的串口调试助手在相应的串口上看到板子的启动信息:
通过修改project-spec/configs/init-ifupdown/interfaces文件,使得打包到文件系统中的/et/network/interfaces中的IP就是静态IP。
x# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8) # The loopback interfaceauto loiface lo inet loopback
# Wireless interfacesiface wlan0 inet dhcp wireless_mode managed wireless_essid any wpa-driver wext wpa-conf /etc/wpa_supplicant.conf
iface atml0 inet dhcp
# Wired or wireless interfacesauto eth0/*********修改部分***********/#iface eth0 inet dhcpiface eth0 inet static address 192.168.3.182 netmask 255.255.255.0 gateway 192.168.3.1 dns-nameservers 8.8.8.8
auto eth1iface eth1 inet dhcp
# Ethernet/RNDIS gadget (g_ether)# ... or on host side, usbnet and random hwaddriface usb0 inet static address 192.168.7.2 netmask 255.255.255.0 network 192.168.7.0 gateway 192.168.7.1
# Bluetooth networkingiface bnep0 inet dhcp修改IP地址为静态IP有两种办法,一种是通过petalinux打包到文件系统时就是静态IP,一种是系统启动后修改。
开发板上的PS_NET网口对应的eth0,PL_NET网口对应的是eth1。
eth0默认的IP分配方式是DHCP。如果希望IP地址固定,可以通过PS_UART对应的console串口编辑/etc/network/interfaces文件,将网口配置成静态IP地址,这样后面就可以通过telnet的方式登录开发板。
xxxxxxxxxxroot@petalinux-mind:~# vi /etc/network/interfaces将eth0配置期望的IP地址,这里时配置成了192.168.3.184
xxxxxxxxxx# Wired or wireless interfacesauto eth0#iface eth0 inet dhcpiface eth0 inet static address 192.168.3.184 netmask 255.255.255.0 gateway 192.168.3.1 dns-nameservers 8.8.8.8
为了更方便的在主机和开发板之间传输文件和登录开发板,可以开启开发板的FTP功能和telnet功能。
为了开启开发板的FTP server功能,需要在Busybox Configuration时开启-w选项:
xxxxxxxxxx petalinux-config -c busybox -> Networking utilities -> ftpd -> [*] Enable -w option在电脑上,通过FileZilla软件连接开发板的ftp服务端。如果没有开启-w选项,则会出错:
开启telnet和ftp功能也有两种方式:一种是打包到文件系统时相应的配置就修改成期望的配置;一种是系统启动后修改配置文件。
如果project-spec/meta-user/recipes-core/busybox目录下没有下图中busybox_%.bbappend文件和busybox文件夹,则需要创建busybox_%.bbappend文件和busybox文件夹,并在busybox文件夹下创建文档inetd.conf。
inetd.conf内容如下:
xxxxxxxxxx#/etc/inetd.conf: see inetd(8) for further informations.## Internet server configuration database## If you want to disable an entry so it isn't touched during# package updates just comment it out with a single '#' character.## <service_name> <sock_type> <proto> <flags> <user> <server_path> <args>##:INTERNAL: Internal services#echo stream tcp nowait root internal#echo dgram udp wait root internal#chargen stream tcp nowait root internal#chargen dgram udp wait root internal#discard stream tcp nowait root internal#discard dgram udp wait root internal#daytime stream tcp nowait root internal#daytime dgram udp wait root internal#time stream tcp nowait root internal#time dgram udp wait root internaltelnet stream tcp nowait root telnetd telnetd -iftp stream tcp nowait root ftpd ftpd -w 如果之前已经有busybox_%.bbappend文件,则在此文件中添加以下内容:
xxxxxxxxxxdo_install_append() { if [ -f ${D}${sysconfdir}/inetd.conf ]; then mv ${D}${sysconfdir}/inetd.conf ${D}${sysconfdir}/inetd.conf.bak fi
install -m 0644 ${WORKDIR}/inetd.conf ${D}${sysconfdir}/inetd.conf}如果之前没有busybox_%.bbappend文件,则创建busybox_%.bbappend文档,内容如下:
xxxxxxxxxxSRC_URI += ""
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
do_install_append() { # bakup origin inetd.conf if [ -f ${D}${sysconfdir}/inetd.conf ]; then mv ${D}${sysconfdir}/inetd.conf ${D}${sysconfdir}/inetd.conf.bak fi
# install new inetd.conf install -m 0644 ${WORKDIR}/inetd.conf ${D}${sysconfdir}/inetd.conf}之后通过petalinux进行build和package。
系统启动后,可以通过console串口编辑/etc/inetd.conf文件。
xxxxxxxxxxroot@petalinux-mind:~# vi /etc/inetd.conf将最后两行改成如下内容:
xxxxxxxxxx#/etc/inetd.conf: see inetd(8) for further informations.## Internet server configuration database## If you want to disable an entry so it isn't touched during# package updates just comment it out with a single '#' character.## <service_name> <sock_type> <proto> <flags> <user> <server_path> <args>##:INTERNAL: Internal services#echo stream tcp nowait root internal#echo dgram udp wait root internal#chargen stream tcp nowait root internal#chargen dgram udp wait root internal#discard stream tcp nowait root internal#discard dgram udp wait root internal#daytime stream tcp nowait root internal#daytime dgram udp wait root internal#time stream tcp nowait root internal#time dgram udp wait root internaltelnet stream tcp nowait root telnetd telnetd -iftp stream tcp nowait root ftpd ftpd -w
在开发板上电后,并且网路正常连接后,在电脑上打开命令提示符,输入telnet 192.168.3.184即可访问开发板。如果提示输入用户名和密码,默认的用户名和密码都是root。也可以通过ftp工具向开发板上传文件或从开发板下载文件。
在console串口上,输入”ifconfig"命令进行查看IP:IP地址:192.168.3.184
xxxxxxxxxxifconfig在主机通过ping能够正常通信。说明该网络可以正常使用。TODO:更换为ping 192.168.3.184的截图
PL_NET对应的网口对应eth1,可以通过命令“ifconfig eth1 +ip地址”进行设置eth1的IP:
xxxxxxxxxxifconfig eth1 192.168.3.185但是这时并不能ping通eth1。这是由于现在开发板上的两个网口配置到了相同的网段,系统路由时默认通过eth0。所以如果想ping通eth1,就得先通过命令断开网口0的连接,并打开网口1的连接,或者将eth1配置到别的网段上。
xxxxxxxxxxifconfig eth0 downifup eth1此时就可以ping通: